s = input()
numbers = {'zero':0,
           'one':1,
           'two':2,
           'three':3,
           'four':4,
           'five':5,
           'six':6,
           'seven':7,
           'eight':8,
           'nine':9
           }
s_arr = s.split()
num_s = ""

def get_primes(n):
    sieve = [True] * n
    primes = []
    for p in range(2, n):
        if sieve[p]:
            primes.append(p)
        for i in range(p * p, n, p):
            sieve[i] = False
    return primes

if (len(s_arr)==3):
    for i in s_arr:
        if i in numbers.keys():
            num_s = num_s + str(numbers[i])
        else:
            print('Wrong input')
            break
    else:
        prost = get_primes(1000)
        k = int(num_s)
        m = 1203021
        print(prost[min(range(len(prost)), key = lambda i: abs(prost[i]-k))])
else:
    print('Wrong input') 

